home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3006
/
3006.xpi
/
chrome
/
dwhelper.jar
/
content
/
twitter.xml
< prev
next >
Wrap
Extensible Markup Language
|
2010-01-15
|
8KB
|
269 lines
<?xml version="1.0"?>
<!-- *****************************************************************************
* Copyright (c) 2006-2007 Michel Gutierrez. All Rights Reserved.
****************************************************************************** -->
<!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="TwitterPref" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox flex="1">
<spacer flex="1"/>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row anonid="xStatusRow" hidden="true">
<label value="&twitter.pref.last-check;"/>
<description anonid="xStatus" class="feature-descr" style="max-height: 20px; overflow: auto;"/>
</row>
<row align="center">
<label value="&twitter.pref.username;"/>
<textbox anonid="xUsername" oninput="this.parentNode.parentNode.parentNode.parentNode.parentNode.changedCredentials()"/>
</row>
<row align="center">
<label value="&twitter.pref.password;"/>
<DHPassword anonid="xPassword" oninput="this.parentNode.parentNode.parentNode.parentNode.parentNode.changedCredentials()"/>
</row>
</rows>
</grid>
<checkbox anonid="xTag" label="&twitter.label.tag-message;"/>
<spacer flex="1"/>
<hbox>
<button anonid="xCreateBut" label="&mp3tunes.pref.create-account;" oncommand="this.parentNode.parentNode.parentNode.signup()"/>
<spacer flex="1"/>
<button label="&mp3tunes.pref.check-account;" oncommand="this.parentNode.parentNode.parentNode.verifyCredentials()"/>
</hbox>
</vbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.twitter=Components.classes['@downloadhelper.net/twitter-processor;1'].
getService(Components.interfaces.dhITwitter);
this.setAttribute("onsyncfrompreference","this.onSyncFromPreference(event)");
this.setAttribute("onsynctopreference","this.onSyncToPreference(event)");
var prefService=Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
this.pref=prefService.getBranch("dwhelper.twitter.");
setTimeout(function(_this) { _this.updateStatus(); },0,this);
]]>
</constructor>
<method name="onSyncFromPreference">
<parameter name="event"/>
<body>
<![CDATA[
this.xUsername.value=this.pref.getCharPref("username");
setTimeout(function(_this) {
var password=_this.util.getPassword("twitter");
_this.xPassword.value=(password!=null)?password:"";
},0,this);
this.xTag.checked=this.pref.getBoolPref("tag-message");
]]>
</body>
</method>
<method name="onSyncToPreference">
<parameter name="event"/>
<body>
<![CDATA[
this.pref.setCharPref("username",this.xUsername.value);
if(this.xPassword.valueSet)
this.util.setPassword("twitter",this.xPassword.value);
this.pref.setBoolPref("tag-message",this.xTag.checked);
]]>
</body>
</method>
<method name="verifyCredentials">
<body>
<![CDATA[
function VerifyCredentialsObserver(client) {
this.client=client;
}
VerifyCredentialsObserver.prototype={
observe: function(subject,topic,data) {
if(topic=="twitter-credentials") {
this.client.updateStatus();
}
}
}
while(this.xStatus.firstChild)
this.xStatus.removeChild(this.xStatus.firstChild);
this.xStatus.appendChild(document.createTextNode(this.util.getText("twitter.message.verifying-credentials")));
this.disableAll(true);
this.twitter.verifyCredentials(new VerifyCredentialsObserver(this));
]]>
</body>
</method>
<method name="updateStatus">
<body>
<![CDATA[
this.disableAll(false);
var status="unchecked";
try {
status=this.pref.getCharPref("last-status");
} catch(e) {}
this.xStatusRow.setAttribute("hidden","true");
var lastStatusText=null;
switch(status) {
case "unchecked":
this.xCreateBut.setAttribute("hidden","false");
lastStatusText=this.util.getText("twitter.message.account-unchecked");
break;
case "succeeded":
this.xCreateBut.setAttribute("hidden","true");
lastStatusText=this.util.getText("twitter.message.account-verified");
break;
case "failed":
this.xCreateBut.setAttribute("hidden","false");
lastStatusText=this.util.getText("twitter.message.account-failed");
break;
}
if(lastStatusText) {
while(this.xStatus.firstChild)
this.xStatus.removeChild(this.xStatus.firstChild);
this.xStatus.appendChild(document.createTextNode(lastStatusText));
this.xStatusRow.setAttribute("hidden","false");
}
]]>
</body>
</method>
<method name="disableAll">
<parameter name="disable"/>
<body>
<![CDATA[
var tbs=["xUsername","xPassword"];
for(var i in tbs) {
this[tbs[i]].disabled=disable;
}
]]>
</body>
</method>
<method name="changedCredentials">
<body>
<![CDATA[
this.pref.setCharPref("last-status","unchecked");
this.updateStatus();
]]>
</body>
</method>
<method name="signup">
<body>
<![CDATA[
window.open("https://twitter.com/signup?commit=Join!");
]]>
</body>
</method>
</implementation>
</binding>
<binding id="TwitterMessage" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox flex="1">
<hbox>
<label anonid="xUser"/>
<spacer flex="1"/>
<label anonid="xLeft" style="font-size: 24pt;"/>
</hbox>
<textbox anonid="xText" multiline="true" rows="4" cols="35" style="" oninput="this.parentNode.parentNode.updateLength()"/>
<vbox anonid="xSmartNaming" collapsed="true">
<description style="font-style: italic; width: 300px;" flex="1">&twitter.message.smartnaming;</description>
<hbox>
<spacer flex="1"/>
<html:a style="display: block;" onclick="this.parentNode.parentNode.parentNode.parentNode.goToSmartnaming();">&twitter.label.go-to-smartnaming;</html:a>
</hbox>
</vbox>
</vbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.twitter=Components.classes['@downloadhelper.net/twitter-processor;1'].
getService(Components.interfaces.dhITwitter);
]]>
</constructor>
<property name="value">
<setter>
<![CDATA[
this.xText.value=val;
this.updateLength();
]]>
</setter>
<getter>
<![CDATA[
return this.xText.value;
]]>
</getter>
</property>
<property name="user">
<setter>
<![CDATA[
this.xUser.value=Util.getFText("twitter.label.from-user",[val],1);
]]>
</setter>
</property>
<property name="smartNaming">
<setter>
<![CDATA[
this.xSmartNaming.collapsed=val;
]]>
</setter>
</property>
<method name="updateLength">
<body>
<![CDATA[
var left=140-this.twitter.twitterLength(this.xText.value);
this.xLeft.setAttribute("value",""+left);
if(left>=0) {
this.xLeft.style.color="Black";
} else {
this.xLeft.style.color="Red";
}
]]>
</body>
</method>
<method name="goToSmartnaming">
<body>
<![CDATA[
window.open("http://www.downloadhelper.net/smartname.php");
]]>
</body>
</method>
</implementation>
</binding>
</bindings>